﻿function ChangeCode() {

    var date = new Date();
    var myImg = document.getElementById("ImageCheck");
    var GUID = document.getElementById("lblGUID");

    if (GUID != null) {
        if (GUID.innerHTML != "" && GUID.innerHTML != null) {
            myImg.src = "../ValidateCode.aspx?GUID=" + GUID.innerHTML + "&flag=" + date.getMilliseconds()
        }
    }
    return false;
}
function CheckValue() {
    username = $("#txtUsername");
    if (username.val() == "帐号错误") {
        username.val("");
        $("#txtUsername").css("color", "black");
    }
}
function validate() {
    username = $("#txtUsername");
    password = $("#txtPass");
    checkcode = $("#CheckCode");
    if (username.val().length == 0) {
        alert("请输入用户名！");
        username.focus();
        return false;
    }
    if (password.val().length == 0) {
        alert("请输入密码！");
        password.focus();
        return false;
    }

    if (checkcode.val().length == 0) {
        alert("请输入验证码！");
        checkcode.focus();
        return false;
    }
    return true;
}
function GetUserName() {
    var strUser = $("#txtUsername").val();
    var strName = $("#txtName").val();

    if (strUser != "" && strName != strUser) {
        $("#txtAccount").val(strUser);
        $.ajax({
            type: "GET",
            url: "/Ashx/LoginAccountToName.ashx",
            dataType: "text",
            data: { strUser: strUser },
            error: function (e) {
                alert("e.toString()" + "!");
            },
            success: function (result) {
                if (result == "nobody") {
                    $("#txtUsername").attr("value", "帐号错误");
                    $("#txtUsername").css("color", "red");
                }
                else {
                    $("#txtUsername").attr("value", result);
                    $("#txtName").attr("value", result);
                }
            }
        });
    }
}